import java.util.Scanner;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hu
 * Date: 2024-05-09
 * Time: 18:22
 */

public class Test {
    //二分查找
    /*public static int binarySearch(int[] arr, int toFind){
        int left = 0;
        int right = arr.length - 1;
        while(left <= right) {
            int mid  = (left + right) / 2;
            if(arr[mid] > toFind){
                right--;
            }else if(arr[mid] < toFind){
                left++;
            }else{
                return mid;
            }
        }
        return -1;
    }

    public static void main1(String[] args) {
        int[] array = {1,2,3,4,5,6};
        int  ret = binarySearch(array, 5);
        System.out.println(ret);
    }

    //冒泡排序
    public static void maopao(int[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            boolean flg = false;
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j] > arr[j+1] ){
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                    flg = true;
                }
            }
            if(flg == false){
                return;
            }
        }
    }

    public static void main2(String[] args) {
        int[] arr = {17,28,3,41,5,36,7,8};
        maopao(arr);
        for (int i = 0; i < arr.length-1; i++) {
            System.out.print(arr[i] + " ");
        }

    }

    public static int transform(int[] arr){
        for (int i = 0; i < arr.length - 1; i++) {
            arr[i] = arr[i] * 2;
        }
        return 1;
    }

    public static void main3(String[] args) {
        int[] arr = {1,1,2,5,6,};
        transform(arr);
        System.out.println(Arrays.toString(arr));
    }*/
    //奇数在偶数前
    public static int feiji(int[] arr) {
        int left = 0;
        int right = arr.length - 1;
        while (left < right) {
            if (arr[left] % 2 == 1) {
                left++;
            } else if (arr[right] % 2 == 0) {
                right--;
            } else {
                int tmp = arr[right];
                arr[right] = arr[left];
                arr[left] = tmp;
            }
        }
        return 0;
    }

    public static void main4(String[] args) {
        int[] arr = {1, 2, 3, 45, 6, 8};
        feiji(arr);
        System.out.println(Arrays.toString(arr));
    }
    
    
    public static int zhaoshu(int[] arr, int target){
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length; j++) {
                if((arr[j] != arr[i]) && arr[j] + arr[i] == target){
                    System.out.println(i + " " + j);
                }
            }
        }
        return 1;
    }
    public static void main5(String[] args){
        int[] arr = {1,23,4,5,6,7,8,};
        zhaoshu(arr, 30);
    }
    
    public static int once(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            int count = 0;
            for (int j = 0; j < arr.length; j++) {
                if(arr[i] == arr[j]){
                    count++;
                }
            }

            }
        }

        return 0;
    }

    public static void main(String[] args) {
        int[] arr = {1,2,1,2,2,6};
        once(arr);
    }
    
}



